//
//  JiaochengCollectionViewCell.m
//  AStage_shougongke
//
//  Created by 赵磊 on 16/1/17.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "JiaochengCollectionViewCell.h"
#import "UIColor+colorChange.h"
@implementation JiaochengCollectionViewCell
- (void)dealloc
{
    [_photo release];
    [_title release];
    [_writer release];
    [_line release];
    [_popularity release];
    [_color release];
    [super dealloc];
}
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.bgView = [[UIView alloc] init];
//        _bgView.backgroundColor = [UIColor changeColorWithString:self.color];
        _bgView.layer.cornerRadius = 5;
        _bgView.clipsToBounds = YES;
        self.photo = [[UIImageView alloc] init];
        _photo.backgroundColor = [UIColor yellowColor];
        self.title = [[UILabel alloc] init];
        self.title.textColor = [UIColor whiteColor];
//        self.title.backgroundColor = [UIColor redColor];
        _title.font = [UIFont systemFontOfSize:13];
        self.writer = [[UILabel alloc] init];
        _writer.textColor = [UIColor lightGrayColor];
        _writer.font = [UIFont systemFontOfSize:12];
//        _writer.backgroundColor = [UIColor yellowColor];
        self.line = [[UIView alloc] init];
        _line.backgroundColor = [UIColor lightGrayColor];
        self.popularity = [[UILabel alloc] init];
//        _popularity.backgroundColor = [UIColor redColor];
        _popularity.textColor = [UIColor lightGrayColor];
        _popularity.font = [UIFont systemFontOfSize:10];
        [self.contentView addSubview:_bgView];
        [self.bgView addSubview:_photo];
        [self.bgView addSubview:_title];
        [self.bgView addSubview:_writer];
        [self.bgView addSubview:_line];
        [self.bgView addSubview:_popularity];
    }
    return self;
}
- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    _bgView.frame = CGRectMake(0, 0, layoutAttributes.size.width, layoutAttributes.size.height);
    self.photo.frame = CGRectMake(0, 0, _bgView.frame.size.width * 1, _bgView.frame.size.width);
    _title.frame = CGRectMake(layoutAttributes.size.width / 10, layoutAttributes.size.width / 10 + _bgView.frame.size.width, layoutAttributes.size.width / 10 * 8, 20);
    _writer.frame = CGRectMake(layoutAttributes.size.width / 10, layoutAttributes.size.width * 2.5 / 10 + _bgView.frame.size.width, layoutAttributes.size.width / 10 * 8, 20);
    _line.frame = CGRectMake(layoutAttributes.size.width / 10, layoutAttributes.size.width * 4 / 10 + _bgView.frame.size.width, layoutAttributes.size.width / 10 * 8, 1);
    _popularity.frame = CGRectMake(layoutAttributes.size.width / 10, layoutAttributes.size.width * 4.5 / 10 + _bgView.frame.size.width, layoutAttributes.size.width / 10 * 8, 18);
}
@end
